#!/bin/sh
#
# XXX WARNING: at the moment this script also add copyright information

set -x
comment="Copyright (C) 2009 k0wax <k0waxk0wax@gmail.com> This work is licensed under the Creative Commons Attribution-Share Alike 3.0 Unported License. To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to Creative Commons, 171 Second Street, Suite 300, San Francisco, California, 94105, USA."
cmd="pngcrush -q -brute -rem gAMA -rem cHRM -rem iCCP -rem sRGB -rem alla -rem allb -text b Comment"
cmd2="optipng -o7 -i0 -nc -preserve"
dir="$1"
if [ ! $dir ]; then
    echo "prease specify input directory"
    exit 1
fi

for f in `find $dir -iname \*.png`; do
    $cmd "$comment" $f $f.tmp
    $cmd2 $f.tmp
    mv $f.tmp $f
done

